module executor.loading.client.LoadingExecutor;

import msgtrans;
import message.Constants;
import message.MsgDefine;
import google.protobuf;
import client.ImClient;
import std.array;
import command.StartAppCommand;
import std.conv: to;
import hunt.logging;
import core.stdc.string;

@TransportClient(logicClientName)
class LoadingExecutor : AbstractExecutor!(LoadingExecutor){

  @MessageId(MESSAGE.CMD_CONTACTS_RES)
  void loading(TransportContext ctx, MessageBuffer buffer)
  {
    auto res = new ContactRES();
    buffer.data.fromProtobuf!ContactRES(res);
    //TransportSession session = ImClient.getInstance().getImClientByMixId(res.clientId);
    ServerExtend serverExtemd ;//= cast(ServerExtend)buffer.extend;
    memcpy(&serverExtemd,buffer.extend.ptr,ServerExtend.sizeof);
    TransportSession session = ImClient.getInstance().getImClientByMixId(serverExtemd.userId);
    if (session !is null)
    {
      session.send(new MessageBuffer(MESSAGE.CMD_CONTACTS_RES,res.toProtobuf.array));
    } else
    {
      logWarning("client id :%s is closed",res.clientId);
    }
  }
}

